home *** CD-ROM | disk | FTP | other *** search
/ Run Magazine ReRun 1986 May & June / rerun-1986-05-06.d64 / disk reader (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  7KB  |  261 lines

  1. 100 rem disk reader
  2. 180 close4:close1:close15:ok=0:clr
  3. 190 printchr$(147):fori=1to10:printchr$(17);chr$(32);:next
  4. 200 print"just a moment please":gosub2490:t$=chr$(147)+chr$(13)+chr$(13)
  5. 210 fori=1to13:t$=t$+chr$(32):next:fori=1to14:t$=t$+chr$(45):next
  6. 220 fori=1to12:t$=t$+chr$(157):next:t$=t$+"diskreader":fori=1to12
  7. 230 t$=t$+chr$(157):next:fori=1to14:t$=t$+chr$(45):next:t$=t$+chr$(13)
  8. 240 gosub1760:ifde<>5thengosub1220
  9. 250 ondegoto1920,1300,310,1570,2430
  10. 270 get#1,a$:l=l+1:ifl=65535thenl=0
  11. 280 ifst<>0then2280
  12. 290 d=asc(a$+chr$(0)):return
  13. 310 gosub2340:printt$:print:print
  14. 320 ifokthenprint#4,nf$:print#4:print#4
  15. 330 print" start address:   $";
  16. 340 ifokthenprint#4,"start address:   $";
  17. 350 gosub270:l1=d:gosub270:l2=d
  18. 360 l=l1+l2*256:d=l:gosub440:printh$:print:print
  19. 370 ifokthenprint#4,h$:print#4:print#4
  20. 380 gosub270:op=d
  21. 390 gosub440:a$=h$:gosub560
  22. 400 ifpeek(653)then400
  23. 410 ifpeek(197)=13then2280
  24. 420 goto380
  25. 440 h$=""
  26. 450 ifdthena=int(d/16)
  27. 460 h$=mid$("0123456789abcdef",1+d-a*16,1)+h$
  28. 470 d=a:ifdgoto450
  29. 480 iflen(h$)<2thenh$=right$("00"+h$,2)
  30. 490 iflen(h$)=3thenh$=right$("0000"+h$,4)
  31. 500 return
  32. 520 d=0:ifh$>""thenforh=1tolen(h$)
  33. 530 a=asc(mid$(h$,h,1))-48
  34. 540 d=d*16+a+(a>9)*7:next:return
  35. 560 gosub640
  36. 570 printxx$:ifokthenprint#4,xx$
  37. 580 ifot$="brk"orot$="rts"then610
  38. 590 ifleft$(ot$,3)="jmp"then610
  39. 600 return
  40. 610 printdi$:ifokthenprint#4,di$
  41. 620 return
  42. 640 d=l-1:gosub440:ox$=h$
  43. 650 iflen(ox$)<4thenox$=right$("0000"+ox$,4)
  44. 660 ox$="."+ox$:xx$=ox$+chr$(32)+a$+chr$(32)
  45. 670 ot$=left$(r$(op),3)
  46. 680 u$=right$(r$(op),1)
  47. 690 ifu$="*"thengosub760:return
  48. 700 ifu$="?"thengosub760:goto730
  49. 710 onasc(u$)-64gosub780,840,890,910,940,970,1020,1070,1100,1130,1190
  50. 720 h1$="":h2$="":return
  51. 730 if(op<32)or(op>127andop<160)or(op=34)thenreturn
  52. 740 xx$=xx$+chr$(32)+chr$(39)+chr$(18)+chr$(op)+chr$(146):return
  53. 760 xx$=xx$+left$(sp$,15)+ot$:return
  54. 780 ot$=ot$+chr$(32)+chr$(36)
  55. 790 gosub270:gosub440:h1$=h$
  56. 800 gosub270:gosub440:h2$=h$
  57. 810 xx$=xx$+h1$+chr$(32)+h2$+left$(sp$,10)+ot$+h2$+h1$
  58. 820 return
  59. 840 ot$=ot$+chr$(32)+chr$(35)+chr$(36)
  60. 850 gosub270:gosub440:h1$=h$
  61. 860 xx$=xx$+h1$+left$(sp$,13)+ot$+h1$
  62. 870 return
  63. 890 ot$=ot$+chr$(32)+chr$(36):goto850
  64. 910 ot$=ot$+chr$(32)+chr$(36):gosub790
  65. 920 xx$=xx$+chr$(44)+chr$(88):return
  66. 940 ot$=ot$+chr$(32)+chr$(36):gosub790
  67. 950 xx$=xx$+chr$(44)+chr$(89):return
  68. 970 ot$=ot$+chr$(32)+chr$(40)+chr$(36)
  69. 980 gosub850
  70. 990 xx$=xx$+chr$(44)+chr$(88)+chr$(41)
  71. 1000 return
  72. 1020 ot$=ot$+chr$(32)+chr$(40)+chr$(36)
  73. 1030 gosub850
  74. 1040 xx$=xx$+chr$(41)+chr$(44)+chr$(89)
  75. 1050 return
  76. 1070 ot$=ot$+chr$(32)+chr$(36):gosub850
  77. 1080 xx$=xx$+chr$(44)+chr$(88):return
  78. 1100 ot$=ot$+chr$(32)+chr$(36):gosub850
  79. 1110 xx$=xx$+chr$(44)+chr$(89):return
  80. 1130 ot$=ot$+chr$(32)+chr$(36)
  81. 1140 gosub270:ox=d:gosub440:h1$=h$
  82. 1150 ox=ox+(ox>127)*256:d=ox+l:gosub440:ox$=h$
  83. 1160 xx$=xx$+h1$+left$(sp$,13)+ot$+ox$
  84. 1170 return
  85. 1190 ot$=ot$+chr$(32)+chr$(40)+chr$(36)
  86. 1200 gosub790:xx$=xx$+chr$(41):return
  87. 1220 printt$:print:print
  88. 1230 print" output to screen ";
  89. 1240 print"or to printer (s/p)?":print
  90. 1250 geta$:ifa$<>"s"anda$<>"p"then1250
  91. 1260 ok=0:ifa$="p"thenok=1
  92. 1270 ifa$="p"thenopen4,4:print#4
  93. 1280 return
  94. 1300 gosub2340:printt$:print:print
  95. 1310 ifokthenprint#4,chr$(14);nf$:print#4:print#4,chr$(15)
  96. 1320 print" start address:   $";
  97. 1330 gosub270:l1=d:gosub270:l2=d
  98. 1340 l=l1+l2*256:d=l:gosub440:printh$:print:print
  99. 1350 gosub270:gosub270
  100. 1360 ifd=0thenprint:print"e.o.f.":goto2280
  101. 1370 gosub270:n1=d:gosub270:n2=d
  102. 1380 n=n1+n2*256:printn;:ifokthenprint#4,n;
  103. 1390 gosub270
  104. 1400 ifpeek(653)then1400
  105. 1410 ifpeek(197)=13then2280
  106. 1420 ifd=0andokthenprint#4
  107. 1430 ifd=0thenprint:goto1350
  108. 1440 if(peek(212)<>0ord<128)andokthenprint#4,chr$(d);
  109. 1450 if(peek(212)<>0ord<128)thenprintchr$(d);:goto1470
  110. 1460 printba$(d-128);:ifokthenprint#4,ba$(d-128);
  111. 1470 ifokand(d=58ord=44)andpeek(211)>65then1520
  112. 1480 ifok=0and(d=58ord=44)andpeek(211)>36then1520
  113. 1490 ifokandpeek(211)>75then1520
  114. 1500 ifok=0andpeek(211)>38then1520
  115. 1510 goto1390
  116. 1520 z%=peek(212):print:ifokthenprint#4
  117. 1530 tp$=left$(sp$,len(str$(n))+1):poke212,z%
  118. 1540 printtp$;:ifokthenprint#4,tp$;
  119. 1550 goto1390
  120. 1570 gosub2340:printt$:print:print
  121. 1580 ifokthenprint#4,chr$(14);nf$
  122. 1590 ifokthenprint#4,chr$(15):print#4
  123. 1600 ifokthenprint#4:close4:ok=0
  124. 1610 ifokthenopen4,4,7
  125. 1620 nc%=0
  126. 1630 gosub270:ifokthennc%=nc%+1
  127. 1640 ifokandnc%>65thennc%=0:print#4
  128. 1650 ifpeek(653)then1650
  129. 1660 ifpeek(197)=13then2280
  130. 1670 ifokandd=34thenprint#4,chr$(39);
  131. 1680 ifd=34thenprintchr$(39);:goto1630
  132. 1690 ifokandd=13thenprint#4
  133. 1700 ifd=13thenprint:goto1630
  134. 1710 ifokand((d>31andd<128)ord>159)thenprint#4,chr$(d);
  135. 1720 if((d>31andd<128)ord>159)thenprintchr$(d);:goto1630
  136. 1730 printchr$(32);:ifokthenprint#4,chr$(32);
  137. 1740 goto1630
  138. 1760 printt$:print:print
  139. 1770 printtab(3);"(1) read directory":print
  140. 1780 printtab(3);"(2) read basic program":print
  141. 1790 printtab(3);"(3) read & disassemble machine code":print
  142. 1800 printtab(3);"(4) read & display file":print
  143. 1810 printtab(3);"(5) end "
  144. 1820 print:print:printtab(13)"select 1-5   ";
  145. 1830 fori=1to15:geta$:printchr$(157);chr$(191);
  146. 1840 ifa$<>""then1890
  147. 1850 next:fori=1to15:geta$
  148. 1860 printchr$(157);chr$(18);chr$(191);chr$(146);
  149. 1870 ifa$<>""then1890
  150. 1880 next:goto1830
  151. 1890 ifa$<"1"ora$>"5"then1830
  152. 1900 de=val(a$):return
  153. 1920 printt$:print:print" disk name:";
  154. 1930 ifokthenprint#4,"disk name:";
  155. 1940 close1:close15:fl=0:l$="":b$=""
  156. 1950 open1,8,0,"$":open15,8,15
  157. 1960 input#15,e1,e1$
  158. 1970 ife1thenprint:print" disk error: "e1;e1$:goto2280
  159. 1980 fori=1to33:get#1,a$
  160. 1990 l$=l$+a$:next:close1:printl$:print:print:ifokthenprint#4,l$:print#4
  161. 2000 printchr$(18);" blocks     file name          file type"
  162. 2010 ifokthenprint#4,"blocks   file name      file type":print#4
  163. 2020 ifokthenprint#4,di$:print#4
  164. 2030 open1,8,0,"$"
  165. 2040 get#1,a$:get#1,a$:gosub2120
  166. 2050 gosub2120:iffl=1thenclose1:close15:goto2280
  167. 2060 printright$(sp$+str$(l),4);left$(sp$,5);
  168. 2070 ifokthenprint#4,right$(sp$+str$(l),4);left$(sp$,5);
  169. 2080 printleft$(b$+sp$,23);ft$
  170. 2090 ifokthenprint#4,left$(b$+sp$,18);ft$
  171. 2100 goto2050
  172. 2120 b$="":get#1,a$:get#1,a$
  173. 2130 get#1,a$:l=asc(a$+chr$(0))
  174. 2140 get#1,a$:l=l+asc(a$+chr$(0))*256
  175. 2150 get#1,a$:input#15,e1,e1$:ife1thenprint:print" disk error: "e1;e1$:goto2280
  176. 2160 ifa$=""thenfl=1:return
  177. 2170 ifa$<>chr$(34)then2150
  178. 2180 get#1,a$
  179. 2190 ifpeek(653)then2190
  180. 2200 ifa$=chr$(34)then2220
  181. 2210 b$=b$+a$:goto2180
  182. 2220 get#1,a$:ifa$=chr$(32)then2220
  183. 2230 ft$=a$
  184. 2240 get#1,a$:ft$=ft$+a$:get#1,a$:ft$=ft$+a$
  185. 2250 get#1,a$:ifa$<>""then2250
  186. 2260 return
  187. 2280 ifokthenprint#4
  188. 2290 close1:close4:close15:ok=0
  189. 2300 print"":printleft$(sp$,13);chr$(18);"hit any key"
  190. 2310 poke198,0:wait198,1:poke198,0
  191. 2320 goto240
  192. 2340 printt$:print:print
  193. 2350 input" name of file : ";nf$:print
  194. 2360 input" file type (prg/seq/usr) : ";tf$:print" looking for: ";nf$;",";tf$
  195. 2370 open15,8,15,"i0"
  196. 2380 open1,8,5,"0:"+nf$+","+left$(tf$,1)+",r"
  197. 2390 input#15,e1,e1$,e2,e3
  198. 2400 ife1thenprint:print" disk error: "e1;e1$:goto2280
  199. 2410 return
  200. 2430 ifokthenprint#4
  201. 2440 close4:close1:close15:ok=0
  202. 2450 printt$:fori=1to10:printchr$(17);chr$(29);:next
  203. 2460 print" end of program !!"
  204. 2470 end
  205. 2490 dimba$(76):fori=0to75
  206. 2500 readba$(i):next
  207. 2510 data"end ","for ","next "
  208. 2520 data"data ","input#","input ","dim "," read ","let "
  209. 2530 data"goto ","run","if ","restore ","gosub ","return"
  210. 2540 data"rem","stop","on ","wait ","load ","save "
  211. 2550 data"verify ","def ","poke ","print#","print","cont"
  212. 2560 data"list","clr","cmd ","sys ","open ","close ","get "
  213. 2570 data"new","tab("," to ","fn ","spc("," then "
  214. 2580 data"not"," step "," + "," - "," * "," / "," ^ "," and "," or "
  215. 2590 data"> ","=","<","sgn"," int"," abs","usr","fre"
  216. 2600 data"pos","sqr","rnd","log","exp","cos","sin"
  217. 2610 data"tan","atn","peek","len","str$","val"
  218. 2620 data"asc","chr$","left$","right$","mid$","go"
  219. 2630 data***
  220. 2640 readba$:ifba$<>"***"thenprint"error in basic data":stop
  221. 2650 remassemblyop-codedata
  222. 2660 databrk*,oraf,?,?,?,orac,aslc,?
  223. 2670 dataphp*,orab,asl*,?,?,oraa,asla,?
  224. 2680 databplj,orag,?,?,?,orah,aslh,?
  225. 2690 dataclc*,orae,?,?,?,orad,asld,?
  226. 2700 datajsra,andf,?,?,bitc,andc,rolc,?
  227. 2710 dataplp*,andb,rol*,?,bita,anda,rola,?
  228. 2720 databmij,andg,?,?,?,andh,rolh,?
  229. 2730 datasec*,ande,?,?,?,andd,rold,?
  230. 2740 datarti*,eorf,?,?,?,eorc,